<template>
  <div>
    <!-- 添加按钮 -->
    <el-button type="primse" @click="add()">添加</el-button>
      <!-- 添加 -->
     <v-add :obj="obj" ref="oCh"></v-add>
     <!-- 列表 -->
     <v-list @edit="edit" ></v-list>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
//引入子组件
import vAdd from "./compoments/add.vue"
import vList from "./compoments/list.vue"
export default {
  props: [],
  components: {
    vAdd,
    vList
  },
  data() {
    return {
      obj:{
          isShow:false,
        // 这个isAdd用来标识你点的是编辑还是添加
        isAdd:false
      }
    };
  },
  computed: {
    ...mapGetters({}),
  },
  methods: {
    ...mapActions({}),
    add(){
      this.obj.isShow =true,
      this.obj.isAdd = true
    },
     // list组件点击了编辑
   edit(id){
      this.obj.isShow = true
      this.obj.isAdd = false
      // 还要执行add.vue中的getOne方法
      this.$refs.oCh.getOne(id)
    }
    
  },
  mounted() {},
};
</script>
<style scoped>
</style>